#include <iostream>
using namespace std;

/*无参构造函数想要调用有参构造函数必须使用初始化列表*/
class Person
{
public:
#if 0
    Person()
    {
        cout << "父类无参构造\n";
    }
#endif
    Person(int age) : m_age(age)
    {
        cout << "父类带参构造\n";
    }

private:
    int m_age;
};
class Student : public Person
{
public:
    Student() : Student(0, 0)
    {
        cout << "子类无参构造\n";
    }
#if 0
    Student(int age, int no)
    {
        /*私有属性：子类不可访问*/
        m_age = age;

        m_no = no;
        cout << "子类带参构造\n";
    }
#endif
    Student(int age, int no) : Person(age), m_no(no)
    {

        cout << "子类带参构造\n";
    }

public:
    int m_no;
};
int main()
{
    /*子类构造函数默认会调用父类的无参构造函数*/
    Student stu(18, 2024);
    cout << stu.m_no << endl;
    return 0;
}